package com.itheima.prize.commons.db.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.itheima.prize.commons.db.entity.ViewCardUserHit;
import com.itheima.prize.commons.db.service.ViewCardUserHitService;
import com.itheima.prize.commons.db.mapper.ViewCardUserHitMapper;
import com.itheima.prize.commons.utils.ApiResult;
import com.itheima.prize.commons.utils.PageBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
* @author shawn
* @description 针对表【view_card_user_hit】的数据库操作Service实现
* @createDate 2023-12-26 11:58:48
*/
@Service
public class ViewCardUserHitServiceImpl extends ServiceImpl<ViewCardUserHitMapper, ViewCardUserHit>
    implements ViewCardUserHitService{
    @Autowired
    private ViewCardUserHitMapper viewCardUserHitMapper;

    @Override
    public ApiResult<PageBean<ViewCardUserHit>> getMyProduct(int gameid, int curpage, int limit, int userId) {
        QueryWrapper<ViewCardUserHit> wrapper = new QueryWrapper<>();
        if(gameid!=-1){
            wrapper.eq("gameid",gameid);
        }
        wrapper.eq("userid",userId);
        Page<ViewCardUserHit> page = Page.of(curpage, limit);
        Page<ViewCardUserHit> viewCardUserHitPage = viewCardUserHitMapper.selectPage(page, wrapper);
        PageBean<ViewCardUserHit> pageBean = new PageBean<>(curpage, limit, viewCardUserHitPage.getTotal(), viewCardUserHitPage.getRecords());
        return new ApiResult(1,"成功",pageBean);
    }

}




